package com.red.wood.module.eval.service.impl;

import java.util.List;
import java.util.Map;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.red.wood.common.util.CommonUtils;
import com.red.wood.common.util.IMap;
import com.red.wood.module.eval.dao.EvalProjectDao;
import com.red.wood.module.eval.service.EvalProjectService;

@Service
@Transactional
public class EvalProjectServiceImpl implements EvalProjectService{

	@Autowired
	private EvalProjectDao evalProjectDao;
	
	@Override
	public void add(Map<String, Object> paramMap) {
		evalProjectDao.add(paramMap);
	}

	@Override
	public void update(IMap paramMap) {
		evalProjectDao.update(paramMap);
	}

	@Override
	public List<Map<String, Object>> getData(String singleTaskId) {
		return evalProjectDao.getData(singleTaskId);
	}

	@Override
	public int getCountBySingleTaskId(String singleTaskId) {
		return evalProjectDao.getCountBySingleTaskId(singleTaskId);
	}

	@Override
	public int getBySingleTaskIdAndIndex(String singleTaskId, String realIndex, String type) {
		return evalProjectDao.getBySingleTaskIdAndIndex(singleTaskId, realIndex, type);
	}

	@Override
	public List<Map<String, Object>> getBySingleTaskIdAndResult(
			String singleTaskId, String result) {
		return evalProjectDao.getBySingleTaskIdAndResult(singleTaskId, result);
	}

	@Override
	public int getEvalProjectResult(String singleTaskId) {
		List<Map<String,Object>> list = evalProjectDao.getEvalProjectResult(singleTaskId);
		int count = 0;
		if(list != null && list.size() > 0) {
			count = Integer.parseInt(CommonUtils.valueOf(list.get(0).get("count")));
		}
		return count;
	}

}
